package com.hd.common.taobao;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.taobao.api.internal.util.WebUtils;

public class DefaultWeiboAppManager {

	private String weiboUrl = "https://api.weibo.com/oauth2/access_token";
	public JSONObject getAuthInfoByCode(String code,String appKey,String appSecret,String redirectUrl){
		Map<String, String> params = new HashMap<String, String>();
		params.put("client_id", appKey);
		params.put("redirect_uri",
				redirectUrl);
		params.put("code", code);
		params.put("client_secret",
				appSecret);
		params.put("grant_type", "authorization_code");
		String response = "";
		try {
			response = WebUtils.doPost(weiboUrl,
					params, 0, 0);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JSONObject object = JSONObject.parseObject(response);
		return object;
	}
}
